<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../../../component/pear/css/pear.css" />
</head>
<body>
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">
                <div class="layui-form-item">
                    <label class="layui-form-label">编号</label>
                    <div class="layui-input-block">
                        <input type="text" name="id" th:value="${id}" required  lay-verify="required" autocomplete="off"  class="layui-input" disabled>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">设备名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="equipmentName" th:value="${equipmentName}" required  lay-verify="required" autocomplete="off" placeholder="请输入设备名称" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">颜色</label>
                    <div class="layui-input-block">
                        <input type="text"  name="color" th:value="${color}" required  lay-verify="required" autocomplete="off" placeholder="请输入颜色" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">尺寸</label>
                    <div class="layui-input-block">
                        <input type="text"  name="size" th:value="${size}" required lay-verify="required" autocomplete="off" placeholder="请输入尺寸" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">设备使用年限</label>
                    <div class="layui-input-block">
                        <input type="text"  name="useAge" th:value="${useAge}" lay-verify="required" autocomplete="off" placeholder="请输入设备使用年限" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">设备使用状态</label>
                    <div class="layui-input-block">
                        <input type="radio" name="useStatus" value="1" title="未使用" th:attr ="checked=${useStatus eq 1 ? true : false}">
                        <input type="radio" name="useStatus" value="2" title="使用中" th:attr ="checked=${useStatus eq 2 ? true : false}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">设备价格</label>
                    <div class="layui-input-block">
                        <input type="number" name="price" th:value="${price}" lay-verify="required" autocomplete="off" placeholder="请输入价格" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">设备健康状态</label>
                    <div class="layui-input-block">
                        <input type="radio" name="healthStatus" value="1" title="正常" th:attr ="checked=${healthStatus eq 1 ? true : false}" >
                        <input type="radio" name="healthStatus" value="2" title="待维修" th:attr ="checked=${healthStatus eq 1 ? true : false}" >
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit lay-filter="equipment-edit">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>
<script>



layui.use(['form','jquery'],function(){
    let form = layui.form;
    let $ = layui.jquery;

    form.on('submit(equipment-edit)', function(data){

        $.ajax({
            url:'/equipment/editEquipment',
            data:JSON.stringify(data.field),
            dataType:'json',
            contentType:'application/json',
            type:'post',
            success:function(result){
                if(result.code === 0){
                    layer.msg(result.msg,{icon:1,time:1000},function(){
                        parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                        parent.layui.table.reload("equipment-table");
                    });
                }else{
                    layer.msg(result.msg,{icon:2,time:1000});
                }
            }
        })
        return false;
    });
})
</script>
<script>
</script>
</body>
</html>
